<?php
namespace app\decorate\model;
use app\BaseModel;
use think\facade\Db;



class Config extends BaseModel
{
    //定义表名 文章表
    protected $name = 'longbing_card_decorate_config';


    public function getBannerAttr($value,$data){

        if(!empty($value)){

            return explode(',',$value);
        }

    }

    /**
     * @author chenniang
     * @DataTime: 2021-01-06 17:59
     * @功能说明:
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->find();

        if(empty($data)){

            $dis['banner'] = '';

            $this->insert($dis);

            $data = $this->where($dis)->find();

        }

        return $data->toArray();

    }


    /**
     * @author chenniang
     * @DataTime: 2021-01-06 18:00
     * @功能说明:编辑
     */
    public function dataUpdate($dis,$data){

        if(isset($data['banner'])){

            $data['banner'] = implode(',',$data['banner']);
        }

        $res = $this->where($dis)->update($data);

        return $res;


    }



}